<template>
  <div class="tabs">
    <button
      :class="['tab-button', { active: item === activeBtn }]"
      v-for="(item, index) in buttons"
      @click="handleClick(item)"
      :key="index"
    >
      {{ item }}
    </button>
    <div class="tab" :is="activeBtn"></div>
  </div>
</template>

<script>
import home from "@/components/tabs/home.vue";
import email from "@/components/tabs/email.vue";
import mine from "@/components/tabs/mine.vue";
import charge from "@/components/tabs/charge.vue";
export default {
  data() {
    return {
      buttons: ["email", "charge", "mine", "home"],
      activeBtn: "email",
    };
  },
  methods: {
    handleClick(item) {
      this.activeBtn = item;
    },
  },
  components: {
    home,
    email,
    charge,
    mine,
  },
};
</script>

<style scoped>
.tab-button {
  padding: 6px 10px;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  border: 1px solid #ccc;
  cursor: pointer;
  background: #f0f0f0;
  margin-bottom: -1px;
  margin-right: -1px;
}

.tab-button:hover {
  background: #e0e0e0;
}

.tab-button.active {
  background: hotpink;
}

.tab {
  border: 1px solid #ccc;
  padding: 10px;
}
h1 {
  margin: 0;
}
</style>
